<script type="text/javascript">
// ********************* Grid admin_users START
var _tm = '{$_tm}';
{literal}
function submit_ajax_grid_admin_users(page) {
	var pars = 'admin_users_grid_page=' + page + '&' + '_tm=' + _tm;

	fade_out_div();
	var myAjax = new Ajax.Request(
                                    "ajax/grids/admin_users_grid.php",
                                    {
                                                method: 'get',
                                                onComplete: admin_users_result,
                                                onSuccess: admin_users_on_success,
                                                onFailure: admin_users_on_failure,
												parameters: pars
                                    }          );
}


function admin_users_result(req, json) {
	if (json) {
		var old_tm = _tm;
		_tm = json._tm;

		// refreshing _tm on all links that are outside of updated area
		for (var i=0; i < document.links.length; i++) {
 		  	document.links[i].href = document.links[i].href.replace(old_tm, _tm);
		}


		if (json.result_code == 1) { // OK
				switch(json.command) {
					case 'redirect':
						window.location = json.command_value;
						break;
					case 'show' :
					default :
						grid_div = $('admin_users_grid_div');
						grid_div.innerHTML = req.responseText;
						break;
				}
		} else {
				// something is wrong
				if (_site_mode == 0) {
					//if in development mode - show the output anyway (if any).
					grid_div = $('admin_users_grid_div');
					grid_div.innerHTML = req.responseText;
				}
		}
	} else {
		// no result_code, some serious error/exception occured.
		if (_site_mode == 1) {
			window.location = _server_error_page;
		} else {
			//if in development mode - show the output anyway (if any).
			grid_div = $('admin_users_grid_div');
			grid_div.innerHTML = req.responseText;
		}
	}
}


function fade_out_div() {
	var overlay = $('admin_users_overlay');
	var grid_div = $('admin_users_grid_div');

	Position.clone(grid_div, overlay)
	var image = $('admin_users_waiting');

	overlay.style.display = 'block';
	var image_top_offset = Math.round((overlay.offsetHeight - image.height) / 2);
	image.style.marginTop = image_top_offset + 'px';
}


function fade_in_div() {
	var overlay = $('admin_users_overlay');
	overlay.style.display = 'none';
}


function admin_users_on_success() {
	fade_in_div();
}


function admin_users_on_failure() {
	fade_in_div();
}


function admin_users_page_change() {
	var page = $F('admin_users_field_page');
	submit_ajax_grid_admin_users(page);
}


{/literal}
// ********************* Grid admin_users END
</script>

<div id="admin_users_grid_div">
<a href="/admin/admin_user/admin_user_edit.php?admin_user_add_new=1" class="action_add">Create new admin user</a><br /><br />
{include file="modules/admin_panel/grids/admin_users_grid.tpl"}
</div>
<div class="metallic_ajax_overlay_grid" id="admin_users_overlay" style="display:none; position: absolute; z-index: 90;" align="center"><img src="img/modules/grid_html_tpl_static_ajax_metallic/indicator_medium.gif" onclick="return true;" id="admin_users_waiting" alt="" /></div>